﻿using AuthCenter_HuangJingtao.Domain;
using AuthCenter_HuangJingtao.ErrorCode;
using AuthCenter_HuangJingtao.Infrastructure.Imterfaces;
using AuthCenter_HuangJingtao.Read.Api.Application.Command.ReversoaLL;
using MediatR;

namespace AuthCenter_HuangJingtao.Read.Api.Application.CommandHandler.ReversoaLL
{
    public class AddReversoaLLCommandHandler : IRequestHandler<AddReversoaLLCommand, ApiResult<int>>
    {
        IBaseReponsitory<Reverso> Reverso;

        public AddReversoaLLCommandHandler(IBaseReponsitory<Reverso> Reverso)
        {
            this.Reverso = Reverso;
        }

        public async Task<ApiResult<int>> Handle(AddReversoaLLCommand request, CancellationToken cancellationToken)
        {
            request.Reverso.Reverso_CreateTime = DateTime.Now;

            await Reverso.AddAsync(request.Reverso);
            return new ApiResult<int> 
            {
                Code = ApiEnum.Success,
                Message = "添加成功",
                Data = 1
            };
        }
    }
}
